package com.xongxong.admin.web.config;

import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import com.xongxong.domain.entity.UserInfo;
import com.xongxong.domain.vo.userVo;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.TimeUnit;

@Configuration
public class GuavaConfig {

    /**
     * userInfoCache
     * @return
     */
    @Bean(name = "userInfoCache")
    public Cache<String, userVo> userInfoCache() {
        return CacheBuilder.newBuilder()
                .expireAfterWrite(1, TimeUnit.DAYS)
                .build();
    }


    /**
     * 验证码缓存-阅后即焚
     * @return
     */
    @Bean(name = "codeToken")
    public Cache<String, String> codeToken() {
        return CacheBuilder.newBuilder()
                .expireAfterWrite(5, TimeUnit.MINUTES)
                .build();
    }

}